<?php

namespace designpatterns;


use designpatterns\facade\Env;
use designpatterns\factory\ShapeFactory;
use designpatterns\observer\other\NewsPublisher;
use designpatterns\observer\other\User;
use designpatterns\single\Database;

//引入文件
require_once __DIR__ . '/vendor/autoload.php';


class index
{

    public function index()
    {
        //工厂模式
       /* $circle = ShapeFactory::createShape('circle',10);
        $square = ShapeFactory::createShape('square',9);
        $circle->draw();
        $square->draw();

        //单例模式
        $singleObject = Database::getInstance();
        $singleObject1 = Database::getInstance();
        var_dump($singleObject);
        var_dump($singleObject1);

        //观察者模式
        $publisher = new NewsPublisher();
        $user1 = new User('张三');
        $user2 = new User('李四');
        //用户订阅主体
        $publisher->attach($user1);
        $publisher->attach($user2);
        //发布新闻
        $publisher->publishNews('今天天气晴朗，适合出游！');
        $publisher->publishNews('今天周大福黄金大跳水，全场所有产品半折出售！');
        //用户取消订阅
        $publisher->detach($user1);
        $publisher->publishNews('从明天开始放假，时间2024-05-08~2024-06-01');*/

//        var_dump(Env::class);die();
//        $config = new configLoad();
//        $env = new Env();
//        $host = $env->get('database.host');
//        var_dump($host);
//        die();

        var_dump(Env::get('USERNAME'));

    }
}

$object = new index();
$object->index();
